//
//  HZTabBar.swift
//  555wobo
//
//  Created by 黄某某 on 15/12/16.
//  Copyright © 2015年 黄某某. All rights reserved.
//

import UIKit

class HZTabBar: UITabBar {
    
    private let count = 5
    
    override func layoutSubviews() {
        super.layoutSubviews()
        
        let width = self.bounds.width / CGFloat(count)
        let frame = CGRect(x: 0, y: 0, width: width, height: self.bounds.height)
        
        var index = 0
        for view in self.subviews{
            if view is UIControl && !(view is UIButton){
                view.frame = CGRectOffset(frame, width * CGFloat(index), 0)
                index += index == 1 ? 2 : 1
    
            }
            
        }
        composeButton.frame = CGRectOffset(frame, width * 2.0, 0)
    }
    lazy var composeButton:UIButton = {
        let btn = UIButton()
        btn.setBackgroundImage(UIImage(named: "tabbar_compose_button"), forState: UIControlState.Normal)
        btn.setBackgroundImage(UIImage(named: "tabbar_compose_button_highlighted"), forState: UIControlState.Highlighted)
        
        
        btn.setImage(UIImage(named: "tabbar_compose_icon_add"), forState: UIControlState.Normal)
        btn.setImage(UIImage(named: "tabbar_compose_icon_add_highlighted"), forState: UIControlState.Highlighted)
        self.addSubview(btn)
        
       return btn
    }()


}
